<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>网页计算器</title>
		<script>
			function compute(op){
				var t1 = document.getElementById("t1").value;
				var t2 = document.getElementById("t2").value;
				var t3;
				switch(op){
					case '+' :t3=t1+t2;break;
					case '-' :t3=t1-t2;break;
					case '*' :t3=t1*t2;break;
					case '/' :t3=t1/t2;break;
					
				}
				document.getElementById("t3").value=t3;
			}
		</script>
	</head>
	<body>
		第一个数字：<input type="text" id="t1" /><br />
		第二个数字：<input type="text" id="t2" /><br />
		<input type="button" value="  +  " onclick="compute('+')" />
		<input type="button" value="  -  " onclick="compute('-')" />
		<input type="button" value="  *  " onclick="compute('*')" />
		<input type="button" value="  /  " onclick="compute('/')" /><br /><br />
		两数的运算结果：<input type="text" id="t3" readonly="readonly" /><br />
	</body>
</html>
